package com.inmaytide.website.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author Moss
 * @since May 20, 2016
 */
public class DateUtils {

    public static final String PATTERN_DATETIME = "yyyy-MM-dd HH:mm:ss";

    public static final String PATTERN_DATE = "yyyy-MM-dd";

    public static final String PATTERN_TIME = "HH:mm:ss";

    public static String format(String pattern) {
        return format(LocalDateTime.now(), pattern);
    }

    public static String format(LocalDateTime datetime, String pattern) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
        return formatter.format(datetime);
    }

    public static String getDatetimeStr() {
        return format(PATTERN_DATETIME);
    }

    public static String getDatetimeStr(LocalDateTime datetime) {
        return format(datetime, PATTERN_DATETIME);
    }

    public static String getDateStr() {
        return format(PATTERN_DATE);
    }

    public static String getDateStr(LocalDateTime datetime) {
        return format(PATTERN_DATE);
    }

}
